(deftemplate question
    (slot thisQuestion)
    (slot answer)
)
	
(deftemplate credit (slot name))
(assert (question (thisQuestion nil )(answer nil)))
(assert (credit (name nil)))

(defrule question(declare (salience 400)) (question(thisQuestion nil)(answer nil)) =>
	(printout t "Doriti sa va faceti un credit? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Doriti sa va faceti un credit?")(answer ?r))))

(defrule answer1 (declare (salience 360)) (question (thisQuestion "Doriti sa va faceti un credit?")(answer NU)) =>
	(printout t "La revedere!" crlf))
	
(defrule question0 (declare (salience 340))(question (thisQuestion "Doriti sa va faceti un credit?")(answer DA)) =>
	(printout t "Aveti copie dupa BI? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti copie dupa BI?")(answer ?r))))
	
(defrule answer2 (declare (salience 320)) (question (thisQuestion "Aveti copie dupa BI?")(answer NU)) =>
	(printout t "Faceti o copie dupa BI/CI" crlf))
	
(defrule answer2.2 (question (thisQuestion "Aveti adeverinta de venit?")(answer NU)) =>
	(printout t "Nu aveti toate actele necesare acordarii creditului bancar." crlf))
	
(defrule question0.1(question (thisQuestion "Aveti copie dupa BI?")(answer DA))=>
	(printout t "Aveti adeverinta de venit ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti adeverinta de venit?")(answer ?r))))
	
(defrule question1(question (thisQuestion "Aveti adeverinta de venit?")(answer DA)) =>
	(printout t "Doriti un credit de studii ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Doriti un credit de studii")(answer ?r))))
	
(defrule question2(question (thisQuestion "Doriti un credit de studii")(answer NU)) =>
	(printout t "Aveti fisa fiscala ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti fisa fiscala?")(answer ?r))))
	
(defrule question3 (question (thisQuestion "Doriti un credit de studii")(answer DA)) =>
	(printout t "Aveti diploma de licenta ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti diploma de licenta?")(answer ?r))))
	
(defrule answer3 (question (thisQuestion "Aveti diploma de licenta?")(answer NU)) =>
	(printout t "Nu aveti toate actele necesare." crlf))
	
(defrule question4 (question (thisQuestion "Aveti diploma de licenta?")(answer DA)) =>
	(printout t "Aveti acte doveditoare bursa ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti acte doveditoare bursa?")(answer ?r))))
	
(defrule answer4(question (thisQuestion "Aveti acte doveditoare bursa?")(answer NU)) =>
	(printout t "Nu aveti toate actele necesare." crlf))
	
(defrule question5 (question (thisQuestion "Aveti acte doveditoare bursa?")(answer DA)) =>
	(printout t "Aveti acceptul institutiei de invatamant ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti acceptul institutiei de invatamant?")(answer ?r))))
	
(defrule answer5 (question (thisQuestion "Aveti acceptul institutiei de invatamant?")(answer NU)) =>
	(printout t "Nu aveti toate actele necesare." crlf))
	
(defrule question6 (question (thisQuestion "Aveti acceptul institutiei de invatamant?")(answer DA)) =>
	(assert (credit (name creditDeStudii)))
    (printout t "Vi s-a acordat creditul pentru studii." crlf))
	
(defrule question7 (question (thisQuestion "Aveti fisa fiscala?")(answer DA)) =>
	(printout t "Aveti factura de utilitati ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti factura de utilitati?")(answer ?r))))
	
(defrule question8 (question (thisQuestion "Aveti fisa fiscala?")(answer NU)) =>
	(printout t "Aveti factura performa de la dealer ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti factura performa de la dealer?")(answer ?r))))
	
(defrule question9 (question(thisQuestion "Aveti factura performa de la dealer?")(answer DA)) =>
    (assert (credit (name creditAuto)))
    (printout t "Vi s-a acordat creditul auto." crlf))
	
(defrule answer6 (question(thisQuestion "Aveti factura performa de la dealer?")(answer NU)) =>
    (printout t "Nu aveti toate actele necesare." crlf))
	
(defrule answer7 (question (thisQuestion "Aveti factura de utilitati?")(answer NU)) =>
    (assert (credit (name creditInMagazin)))
    (printout t "Vi s-a acordat creditul in magazin." crlf))
	
(defrule question10 (question (thisQuestion "Aveti factura de utilitati?")(answer DA)) =>
    (printout t "Aveti acte proprietate garantie ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti acte proprietate garantie ?")(answer ?r))))
	
(defrule qquestion11 (question(thisQuestion "Aveti acte proprietate garantie ?")(answer DA)) =>
    (printout t "Aveti extras de carte funciara ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti extras de carte funciara?")(answer ?r))))
	
(defrule answer8(question (thisQuestion "Aveti acte proprietate garantie?")(answer NU)) =>
      (printout t "Nu aveti toate actele necesare." crlf))
	  
(defrule question12 (question (thisQuestion "Aveti extras de carte funciara?")(answer DA)) =>
    (printout t "Aveti raport de evaluare pentru bunul imobiliar adus drept garantie ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti raport de evaluare pentru bunul imobiliar adus drept garantie?")(answer ?r))))
	
(defrule answer9 (question (thisQuestion "Aveti raport de evaluare pentru bunul imobiliar adus drept garantie?")(answer NU)) =>
    (assert (credit (name creditNevoiPersoanale)))
    (printout t "Vi s-a acordat creditul de nevoi speciale." crlf))
	
(defrule question13(question (thisQuestion "Aveti raport de evaluare pentru bunul imobiliar adus drept garantie?")(answer DA)) =>
    (printout t "Aveti documente necesare constituirii ipotecii ? (DA/NU)" crlf)
	(bind ?r (read))
	(assert (question (thisQuestion "Aveti documente necesare constituirii ipotecii?")(answer ?r))))
	
(defrule answer10 (question (thisQuestion "Aveti documente necesare constituirii ipotecii?")(answer NU)) =>
	(printout t "Nu aveti toate actele necesare." crlf))
	
(defrule quesiton14(question (thisQuestion "Aveti documente necesare constituirii ipotecii?")(answer DA)) =>
    (assert (credit (name creditIpotecar)))
    (printout t "Vi s-a acordat creditul ipotecar." crlf))

;(facts)
(agenda)
(run)